package jumpingnotes.model.entity;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import net.jf.lucene.analysis.mmseg.MMSegAnalyzer;

import org.hibernate.search.annotations.Analyzer;
import org.hibernate.search.annotations.DocumentId;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Index;
import org.hibernate.search.annotations.Indexed;
import org.hibernate.search.annotations.Store;

@Entity
@Table(name = "book", catalog = "jumping_notes")
@Indexed
@Analyzer(impl = MMSegAnalyzer.class)
public class Book implements java.io.Serializable
{

	private Integer bookId;
	private String name;
	private String subTitle;
	private String abstract_;
	private String author;
	private String authorIntro;
	private String publishPress;
	private String publishYear;
	private Integer chapterCount;
	private Integer wordCount;
	private Integer completeStatus;
	private String image;
	private String imageBig;
	private String imageSmall;
	private String website;
	private String url;
	private Integer memberId;
	private Integer expectRate;
	private Integer activeLevel;
	private Date createTime;
	private Date updateTime;
	private Set<Chapter> chapters = new HashSet<Chapter>(0);
	private Set<BookVersion> bookVersions = new HashSet<BookVersion>(0);
	private Set<BookTagRelation> bookTagRelations = new HashSet<BookTagRelation>(0);
	private Set<BookExpect> bookExpects = new HashSet<BookExpect>(0);
	private Set<BookFavorite> bookFavorites = new HashSet<BookFavorite>(0);
	private Set<RecordAlbum> recordAlbums = new HashSet<RecordAlbum>(0);
	private Set<BookComment> bookComments = new HashSet<BookComment>(0);
	private Set<BookRecommend> bookRecommends = new HashSet<BookRecommend>(0);

	public Book()
	{
	}

	public Book(String name, String author, Date createTime)
	{
		this.name = name;
		this.author = author;
		this.createTime = createTime;
	}

	public Book(String name, String subTitle, String abstract_, String author, String authorIntro, String publishPress,
			String publishYear, Integer chapterCount, Integer wordCount, Integer completeStatus, String image,
			String imageBig, String imageSmall, String website, String url, Integer memberId, Integer expectRate,
			Integer activeLevel, Date createTime, Date updateTime, Set<Chapter> chapters,
			Set<BookVersion> bookVersions, Set<BookTagRelation> bookTagRelations, Set<BookExpect> bookExpects,
			Set<BookFavorite> bookFavorites, Set<RecordAlbum> recordAlbums, Set<BookComment> bookComments,
			Set<BookRecommend> bookRecommends)
	{
		this.name = name;
		this.subTitle = subTitle;
		this.abstract_ = abstract_;
		this.author = author;
		this.authorIntro = authorIntro;
		this.publishPress = publishPress;
		this.publishYear = publishYear;
		this.chapterCount = chapterCount;
		this.wordCount = wordCount;
		this.completeStatus = completeStatus;
		this.image = image;
		this.imageBig = imageBig;
		this.imageSmall = imageSmall;
		this.website = website;
		this.url = url;
		this.memberId = memberId;
		this.expectRate = expectRate;
		this.activeLevel = activeLevel;
		this.createTime = createTime;
		this.updateTime = updateTime;
		this.chapters = chapters;
		this.bookVersions = bookVersions;
		this.bookTagRelations = bookTagRelations;
		this.bookExpects = bookExpects;
		this.bookFavorites = bookFavorites;
		this.recordAlbums = recordAlbums;
		this.bookComments = bookComments;
		this.bookRecommends = bookRecommends;
	}

	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "book_id", unique = true, nullable = false)
	@DocumentId
	public Integer getBookId()
	{
		return this.bookId;
	}

	public void setBookId(Integer bookId)
	{
		this.bookId = bookId;
	}
	
	@Column(name = "name", nullable = false, length = 100)
	@Field(index = Index.TOKENIZED, store = Store.NO)
	public String getName()
	{
		return this.name;
	}

	public void setName(String name)
	{
		this.name = name;
	}

	@Column(name = "sub_title", length = 100)
	@Field(index = Index.TOKENIZED, store = Store.NO)
	public String getSubTitle()
	{
		return this.subTitle;
	}

	public void setSubTitle(String subTitle)
	{
		this.subTitle = subTitle;
	}

	@Column(name = "abstract")
	@Field(index = Index.TOKENIZED, store = Store.NO)
	public String getAbstract_()
	{
		return this.abstract_;
	}

	public void setAbstract_(String abstract_)
	{
		this.abstract_ = abstract_;
	}

	@Column(name = "author", nullable = false, length = 100)
	@Field(index = Index.TOKENIZED, store = Store.NO)
	public String getAuthor()
	{
		return this.author;
	}

	public void setAuthor(String author)
	{
		this.author = author;
	}

	@Column(name = "author_intro", length = 65535)
	@Field(index = Index.TOKENIZED, store = Store.NO)
	public String getAuthorIntro()
	{
		return this.authorIntro;
	}

	public void setAuthorIntro(String authorIntro)
	{
		this.authorIntro = authorIntro;
	}

	@Column(name = "publish_press", length = 100)
	public String getPublishPress()
	{
		return this.publishPress;
	}

	public void setPublishPress(String publishPress)
	{
		this.publishPress = publishPress;
	}

	@Column(name = "publish_year", length = 10)
	public String getPublishYear()
	{
		return this.publishYear;
	}

	public void setPublishYear(String publishYear)
	{
		this.publishYear = publishYear;
	}

	@Column(name = "chapter_count")
	public Integer getChapterCount()
	{
		return this.chapterCount;
	}

	public void setChapterCount(Integer chapterCount)
	{
		this.chapterCount = chapterCount;
	}

	@Column(name = "word_count")
	public Integer getWordCount()
	{
		return this.wordCount;
	}

	public void setWordCount(Integer wordCount)
	{
		this.wordCount = wordCount;
	}

	@Column(name = "complete_status")
	public Integer getCompleteStatus()
	{
		return this.completeStatus;
	}

	public void setCompleteStatus(Integer completeStatus)
	{
		this.completeStatus = completeStatus;
	}

	@Column(name = "image")
	public String getImage()
	{
		return this.image;
	}

	public void setImage(String image)
	{
		this.image = image;
	}

	@Column(name = "image_big")
	public String getImageBig()
	{
		return this.imageBig;
	}

	public void setImageBig(String imageBig)
	{
		this.imageBig = imageBig;
	}

	@Column(name = "image_small")
	public String getImageSmall()
	{
		return this.imageSmall;
	}

	public void setImageSmall(String imageSmall)
	{
		this.imageSmall = imageSmall;
	}

	@Column(name = "website", length = 100)
	public String getWebsite()
	{
		return this.website;
	}

	public void setWebsite(String website)
	{
		this.website = website;
	}

	@Column(name = "url")
	public String getUrl()
	{
		return this.url;
	}

	public void setUrl(String url)
	{
		this.url = url;
	}

	@Column(name = "member_id")
	public Integer getMemberId()
	{
		return this.memberId;
	}

	public void setMemberId(Integer memberId)
	{
		this.memberId = memberId;
	}

	@Column(name = "expect_rate")
	public Integer getExpectRate()
	{
		return this.expectRate;
	}

	public void setExpectRate(Integer expectRate)
	{
		this.expectRate = expectRate;
	}

	@Column(name = "active_level")
	public Integer getActiveLevel()
	{
		return this.activeLevel;
	}

	public void setActiveLevel(Integer activeLevel)
	{
		this.activeLevel = activeLevel;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "create_time", nullable = false, length = 19)
	public Date getCreateTime()
	{
		return this.createTime;
	}

	public void setCreateTime(Date createTime)
	{
		this.createTime = createTime;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "update_time", length = 19)
	public Date getUpdateTime()
	{
		return this.updateTime;
	}

	public void setUpdateTime(Date updateTime)
	{
		this.updateTime = updateTime;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "book")
	public Set<Chapter> getChapters()
	{
		return this.chapters;
	}

	public void setChapters(Set<Chapter> chapters)
	{
		this.chapters = chapters;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "book")
	public Set<BookVersion> getBookVersions()
	{
		return this.bookVersions;
	}

	public void setBookVersions(Set<BookVersion> bookVersions)
	{
		this.bookVersions = bookVersions;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "book")
	public Set<BookTagRelation> getBookTagRelations()
	{
		return this.bookTagRelations;
	}

	public void setBookTagRelations(Set<BookTagRelation> bookTagRelations)
	{
		this.bookTagRelations = bookTagRelations;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "book")
	public Set<BookExpect> getBookExpects()
	{
		return this.bookExpects;
	}

	public void setBookExpects(Set<BookExpect> bookExpects)
	{
		this.bookExpects = bookExpects;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "book")
	public Set<BookFavorite> getBookFavorites()
	{
		return this.bookFavorites;
	}

	public void setBookFavorites(Set<BookFavorite> bookFavorites)
	{
		this.bookFavorites = bookFavorites;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "book")
	public Set<RecordAlbum> getRecordAlbums()
	{
		return this.recordAlbums;
	}

	public void setRecordAlbums(Set<RecordAlbum> recordAlbums)
	{
		this.recordAlbums = recordAlbums;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "book")
	public Set<BookComment> getBookComments()
	{
		return this.bookComments;
	}

	public void setBookComments(Set<BookComment> bookComments)
	{
		this.bookComments = bookComments;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "book")
	public Set<BookRecommend> getBookRecommends()
	{
		return this.bookRecommends;
	}

	public void setBookRecommends(Set<BookRecommend> bookRecommends)
	{
		this.bookRecommends = bookRecommends;
	}

}
